<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_account" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 信箱 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="信箱账号" prop="mail_account">
              {{s_account.mail_account}}
            </el-form-item>
          </el-col>
        </el-row>
        <input type="hidden" id="mail_password" name="mail_password" :value="s_account.mail_password">
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 收信箱 </span>
      </div>
      <el-table :data="l_mail" @selection-change="handleSelectionChange">
        <el-table-column label="#" align="center" type='selection'>
        </el-table-column>
        <el-table-column label="回复" prop="mail_id">
          <template slot-scope="scope">
            <el-button @click="gotoPage('D971B13A0AA24AB3BF29DE509CDDEE4A?&CMID3='+scope.row.mail_id+''+vueparams+'')" type='primary' size="mini">回复</el-button>
          </template>
        </el-table-column>
        <el-table-column label="转发" prop="mail_id">
          <template slot-scope="scope">
            <el-button @click="gotoPage('/oa/communication/EmailForward?CMID3='+scope.row.mail_id+''+vueparams+'')" type='primary' size="mini">转发</el-button>
          </template>
        </el-table-column>
        <el-table-column label="主题" prop="mail_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/oa/communication/EmailDetailed?CMID3='+scope.row.mail_id+''+vueparams+'')" type='primary'>{{scope.row.subject}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="发送时间" prop="send_time">
        </el-table-column>
        <el-table-column label="接收时间" prop="receive_time">
        </el-table-column>
      </el-table>
      <el-button @click="('')" type='success' size="mini"><i class='fa fa-check'></i>收信</el-button>
      <el-button @click="d_ss('')" :disabled="multiple" type='success' size="mini"><i class='fa fa-check'></i>删除</el-button>
      <el-button @click="gotoPage('/oa/communication/ReceiveEmail?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'Receiver',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        s_account: {
          mail_account: null,
        },
        l_mail: [],
        loading: false,
        elcheck: [],
        multiple: true,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/oa/communication/EmailAction/receiver?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_ss(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/oa/communication/EmailAction/d_ss?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/oa/communication/Receiver/receiver?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      handleSelectionChange(selection) {
        this.elcheck = selection.map(item => item["mail_id"]);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
    },
  }
</script>
